package ui;
import java.util.*;
public class TUI
{
    // instance variables
    private DVDUI dui;
    private PersonUI pui;
    private LoanUI lui;
    /**
     * Constructor for objects of class tui
     */
    public TUI()
    {
        // initialise instance variables
        this.dui = new DVDUI();
        this.pui = new PersonUI();
        this.lui = new LoanUI();
    }

    /**
     * Starter MainMenuen
     */
    public void Start()
    {
        MainMenu();
    }

    /**
     * skriver MainMenu og starter mulige svar muligheder
     */
    private void MainMenu()
    {
        boolean exit = false;
        while(!exit)//that is: while exit is false
        {
            int choice = writeMainMenu(); 
            switch(choice)
            {
                case 1:
                pui.Start();
                break;
                case 2:
                dui.Start();    
                break;
                case 3:
                lui.Start();
                break;
                default:
                exit = true;            
            }
        }
    }

    /**
     * Skriver mainMenu og opretter interface 
     */
    private int writeMainMenu()
    {      // makes an object keyboard to read input from the screen
        Scanner keyboard = new Scanner(System.in);
        System.out.println("*** Main Menu ***");
        System.out.println(" (1) Friends");
        System.out.println(" (2) DVD");
        System.out.println(" (3) Loan");
        System.out.println(" (4) Exit");
        System.out.print("\n Vaelg: ");
        int choise;
        while(!keyboard.hasNextInt()){
            System.out.println("Indtast venligst et tal ");
            keyboard.next(); 
        }
        choise = keyboard.nextInt();
        System.out.print("\n");
        return choise;
    }

}
